home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c,comp.std.c
- Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
- Date: 29 Jan 1996 09:00:10 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4eindq$eju@solutions.solon.com>
- References: <30C40F77.53B5@swsbbs.com> <DLtABq.Fzu@mv.mv.com> <4edqh2$rvl@solutions.solon.com> <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>,
- James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote:
- >In article <4edqh2$rvl@solutions.solon.com> seebs@solutions.solon.com
- >(Peter Seebach) writes:
- >In the particular case which you cite, I do *not* believe that gcc
- >will compile the program without a diagnostic if the program is in a
- >file called a.c. More ever, the compiler documentation definitly
- >states that only programs in files whose names end in .c will be
- >compiled as C. (A legal restriction, as far as I can see.)
-
- That's an interesting question; the standard does not visibly make any
- such requirements, but you could argue that gcc is only a conforming compiler
- when invoked on a file ending in .c.
-
- Yes, it would *have* to give a diagnostic for a Fortran program; nonetheless,
- the program is *still* conforming if it is accepted. I think this is a
- botch; the standard should probably distinguish between extensions and
- violations.
-
- >To tell the truth, I'm not sure what the answer is. The text
- >concerning main is in the chapter describing the environment. It
- >doesn't appear as a semantic restriction or anything. It simply
- >states that on start-up, a function called main will be called, and
- >that the implementation must support the following forms. It doesn't
- >seem (to me, at least) to say anything about what other forms it might
- >support, or what the implementation must do if given a fully other
- >definition of main.
-
- I would tend to expect a diagnostic in strict ANSI mode, and would also
- expect a diagnostic for including <sys/stat.h> in strict ANSI mode. Neither
- is often forthcoming.
-
- gcc warns only on implementations where they consider it a hosted environment;
- on most systems, they weasel and claim to be a freestanding implementation.
-
- >Normally, I would expect (at the very least) a compiler to generate a
- >warning or an error for a main that it did not support. In fact,
- >however, my compiler (gcc) accepts the following definition without
- >the slightest complaint, although I'd rather not think about what will
- >happen when I access parameter d:
-
- > int main( char a , int b , long c , double d )
-
- I think that may actually legitimately require a diagnostic; 5.1.2.2.1 gives
- us a constraint (?) of "If they are defined, the parameters to the main
- function shall obey the following constraints: ..." and some definitions.
-
- I would take this as implying that main *must* conform. I would like to see
- them go from "can be declared" to "shall be declared".
-
- Already, though, it is clear than any main other than those provided makes
- undefined behavior.
-
- >Yes and no. In comp.std.c, the discussion is exactly about what is
- >legal according to the standard. In comp.lang.c (to which this
- >article is also cross-posted), the discussion should generally be a
- >bit more open.
-
- It's debated. Generally, questions about features of specific compilers or
- OS's are off-topic, even when they relate to conforming programs. Only
- strictly conforming programs (or attempts at such, when people are asking
- questions) are going to be usable and testable by the whole readership.
- (I doubt you can find a single extension that works on *all* machines
- we use.)
-
- >Thus, for example, in comp.std.c, a program with a variable named far
- >is illegal, and that is it. In comp.lang.c (and I hope in its
- >moderated variant), I would hope that someone would point out that,
- >legal or not, it's going to get you into trouble.
-
- (I assume you meant "...is legal, ...")
-
- I generally allow some discussion of system arcana in clcm, but try to
- keep it constrained to question s of portability.
-
- It appears that the DOS world has started using __far, so I stopped worrying.
- I declare variables with names like "near" or "far", and if a compiler can't
- take it' the compiler is broken.
-
- I have actually had the "good code, no computer to run it on" problem from
- this attitude, but hey, it's a hobby.
-
- For production code, I cheerfully assume POSIX or other standards.
- (And, of course, *document* those assumptions.)
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1995 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- Using trn? Weird new newsgroup problem? I know the fix! Email me!
- The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq - Not A Flying Toy
-